package
{
	import alternativa.engine3d.core.Mesh;
	import alternativa.engine3d.primitives.Box;
	import alternativa.engine3d.core.Mesh;
	import alternativa.engine3d.materials.FillMaterial;
	import alternativa.engine3d.materials.WireMaterial;
	import alternativa.engine3d.materials.TextureMaterial;
	import alternativa.types.Texture;
	import alternativa.engine3d.events.MouseEvent3D;
	import flash.geom.Point;
	import flash.external.ExternalInterface;
	
	public class Document extends Mesh
	{
		
		[Embed(source="images/logoPDF.jpg")] private static const bmpMur:Class;
		private static const pdfTexture:Texture = new Texture(new bmpMur().bitmapData, "logoPDF.jpg");
		
		public function Document()
		{
			createVertex(0,0,0,1);
			createVertex(0,0,20,2);
			createVertex(20,0,20,3);
			createVertex(20,0,0,4);
			
			createFace([4,1,2,3],"doc");
			setUVsToFace(new Point(0, 0), new Point(1, 0), new Point(1, 1), "doc");
			
			createSurface(["doc"],"surfacedoc");
			setTextureMaterials();		
			
			addEventListener(MouseEvent3D.CLICK,onClick);
		}
		
		public function setTextureMaterials():void
		{
			setMaterialToSurface(new TextureMaterial(pdfTexture),"surfacedoc");
		}
		
		public function onClick(e:MouseEvent3D):void
		{
			ExternalInterface.call("addObject",3);
		}
	}
}